{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y_predict:[ 99.77923717  89.27333798  78.76743878 273.1265739   78.76743878\n",
      " 126.04398516]\n",
      "train score:-2.1723636584179755\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAeVUlEQVR4nO3de7xVVb338c9XQEVS8YKkqKFGeNTy0k4pPd00USuhm9pTieajT2VleSKhPKXVc5LscurYsZAeQ4+laag81ZEUI3tVWggIqIck02R72xqgCSeRfuePOdZisd3sPfZlrrnZ+/t+vdZrzTnmmHP9Bnuzf2uOMeeYigjMzMwAtqk6ADMz6z+cFMzMrM5JwczM6pwUzMyszknBzMzqhlYdQG/svvvuMXbs2KrDMDPbqtx9991PRcSojrZt1Ulh7NixLFy4sOowzMy2KpIe3tI2dx+ZmVmdk4KZmdU5KZiZWZ2TgpmZ1TkpmJlZ3VZ99ZGZ2WBw0+JWLp23gkfXrGevkcOZOnE8kw8fU8pnOSmYmfVjNy1uZfqcZazfsBGA1jXrmT5nGUApicHdR2Zm/dil81bUE0LN+g0buXTeilI+z0nBzKwfe3TN+m6V95aTgplZP7bXyOHdKu8tJwUzs35s6sTxDB82ZLOy4cOGMHXi+FI+zwPNZmb9WG0w2VcfmZkZUCSGspJAe+4+MjOzOicFMzOrc1IwM7M6JwUzM6tzUjAzszonBTMzq3NSMDOzOicFMzOrc1IwM7O6UpOCpPMkLZd0r6RPpLJdJd0q6YH0vksql6RvSVopaamkI8qMzczMXqy0pCDpEOBs4EjgUOBtkl4OTAPmR8Q4YH5aBzgRGJde5wCXlxWbmZl1rM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QN6HCwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.linear_model import LinearRegression\n",
    "#最小二乘线性回归\n",
    "x_train = np.array([1.7, 1.5, 1.3, 5, 1.3, 2.2])\n",
    "\n",
    "y_train = np.array([368, 340, 376, 954, 332, 556])\n",
    "'''\n",
    "fit_intercept:模型中是否包含截距项，如果数据已经中心化(训练样本集的y的均值为0，则设置为False)\n",
    "normalize:是否对输入特征X做归一化（减去均值，除以L2模），使得每个样本的模长为1。\n",
    "          对数据进行归一化会使得超参数学习更鲁棒，且几乎和样本数目没有关系，回归中用的不多，更多的时候用标准化\n",
    "copy_X:是否拷贝数据X，设置为False,X会被重写覆盖\n",
    "n_jobs:并行计算时使用的CPU的数据 -1表示使用所有的CPU资源(与设置为CPU核的数目相同)\n",
    "'''\n",
    "lr = LinearRegression(True, True, False, 4)\n",
    "#在scikit-learn中，训练数据x是二维数组，例子中是单维特征，需要变成二维数组\n",
    "x_train = x_train.reshape(-1, 1)\n",
    "#训练模型参数\n",
    "lr.fit(x_train, y_train)\n",
    "y_predict = lr.predict(x_train)\n",
    "print(\"y_predict:{}\".format(y_predict))\n",
    "score = lr.score(x_train, y_train)\n",
    "print(\"train score:{}\".format(score))\n",
    "plt.scatter(x_train, y_train, label=\"Train Simples\")\n",
    "\n",
    "plt.xlabel(\"online advertising dollars\")\n",
    "plt.ylabel(\"monthly e-commenerce sales\")\n",
    "plt.show()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
